home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Programming / gcc-2.95.3-3 / info / gcc.info-23 < prev    next >
Encoding:
GNU Info File  |  2001-07-15  |  45.3 KB  |  990 lines

  1. This is Info file gcc.info, produced by Makeinfo version 1.68 from the
  2. input file ./gcc.texi.
  3.  
  4. INFO-DIR-SECTION Programming
  5. START-INFO-DIR-ENTRY
  6. * gcc: (gcc).                  The GNU Compiler Collection.
  7. END-INFO-DIR-ENTRY
  8.    This file documents the use and the internals of the GNU compiler.
  9.  
  10.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  11. Boston, MA 02111-1307 USA
  12.  
  13.    Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
  14. 1999, 2000 Free Software Foundation, Inc.
  15.  
  16.    Permission is granted to make and distribute verbatim copies of this
  17. manual provided the copyright notice and this permission notice are
  18. preserved on all copies.
  19.  
  20.    Permission is granted to copy and distribute modified versions of
  21. this manual under the conditions for verbatim copying, provided also
  22. that the sections entitled "GNU General Public License" and "Funding
  23. for Free Software" are included exactly as in the original, and
  24. provided that the entire resulting derived work is distributed under
  25. the terms of a permission notice identical to this one.
  26.  
  27.    Permission is granted to copy and distribute translations of this
  28. manual into another language, under the above conditions for modified
  29. versions, except that the sections entitled "GNU General Public
  30. License" and "Funding for Free Software", and this permission notice,
  31. may be included in translations approved by the Free Software Foundation
  32. instead of in the original English.
  33.  
  34. 
  35. File: gcc.info,  Node: Register Classes,  Next: Stack and Calling,  Prev: Registers,  Up: Target Macros
  36.  
  37. Register Classes
  38. ================
  39.  
  40.    On many machines, the numbered registers are not all equivalent.
  41. For example, certain registers may not be allowed for indexed
  42. addressing; certain registers may not be allowed in some instructions.
  43. These machine restrictions are described to the compiler using
  44. "register classes".
  45.  
  46.    You define a number of register classes, giving each one a name and
  47. saying which of the registers belong to it.  Then you can specify
  48. register classes that are allowed as operands to particular instruction
  49. patterns.
  50.  
  51.    In general, each register will belong to several classes.  In fact,
  52. one class must be named `ALL_REGS' and contain all the registers.
  53. Another class must be named `NO_REGS' and contain no registers.  Often
  54. the union of two classes will be another class; however, this is not
  55. required.
  56.  
  57.    One of the classes must be named `GENERAL_REGS'.  There is nothing
  58. terribly special about the name, but the operand constraint letters `r'
  59. and `g' specify this class.  If `GENERAL_REGS' is the same as
  60. `ALL_REGS', just define it as a macro which expands to `ALL_REGS'.
  61.  
  62.    Order the classes so that if class X is contained in class Y then X
  63. has a lower class number than Y.
  64.  
  65.    The way classes other than `GENERAL_REGS' are specified in operand
  66. constraints is through machine-dependent operand constraint letters.
  67. You can define such letters to correspond to various classes, then use
  68. them in operand constraints.
  69.  
  70.    You should define a class for the union of two classes whenever some
  71. instruction allows both classes.  For example, if an instruction allows
  72. either a floating point (coprocessor) register or a general register
  73. for a certain operand, you should define a class `FLOAT_OR_GENERAL_REGS'
  74. which includes both of them.  Otherwise you will get suboptimal code.
  75.  
  76.    You must also specify certain redundant information about the
  77. register classes: for each class, which classes contain it and which
  78. ones are contained in it; for each pair of classes, the largest class
  79. contained in their union.
  80.  
  81.    When a value occupying several consecutive registers is expected in a
  82. certain class, all the registers used must belong to that class.
  83. Therefore, register classes cannot be used to enforce a requirement for
  84. a register pair to start with an even-numbered register.  The way to
  85. specify this requirement is with `HARD_REGNO_MODE_OK'.
  86.  
  87.    Register classes used for input-operands of bitwise-and or shift
  88. instructions have a special requirement: each such class must have, for
  89. each fixed-point machine mode, a subclass whose registers can transfer
  90. that mode to or from memory.  For example, on some machines, the
  91. operations for single-byte values (`QImode') are limited to certain
  92. registers.  When this is so, each register class that is used in a
  93. bitwise-and or shift instruction must have a subclass consisting of
  94. registers from which single-byte values can be loaded or stored.  This
  95. is so that `PREFERRED_RELOAD_CLASS' can always have a possible value to
  96. return.
  97.  
  98. `enum reg_class'
  99.      An enumeral type that must be defined with all the register class
  100.      names as enumeral values.  `NO_REGS' must be first.  `ALL_REGS'
  101.      must be the last register class, followed by one more enumeral
  102.      value, `LIM_REG_CLASSES', which is not a register class but rather
  103.      tells how many classes there are.
  104.  
  105.      Each register class has a number, which is the value of casting
  106.      the class name to type `int'.  The number serves as an index in
  107.      many of the tables described below.
  108.  
  109. `N_REG_CLASSES'
  110.      The number of distinct register classes, defined as follows:
  111.  
  112.           #define N_REG_CLASSES (int) LIM_REG_CLASSES
  113.  
  114. `REG_CLASS_NAMES'
  115.      An initializer containing the names of the register classes as C
  116.      string constants.  These names are used in writing some of the
  117.      debugging dumps.
  118.  
  119. `REG_CLASS_CONTENTS'
  120.      An initializer containing the contents of the register classes, as
  121.      integers which are bit masks.  The Nth integer specifies the
  122.      contents of class N.  The way the integer MASK is interpreted is
  123.      that register R is in the class if `MASK & (1 << R)' is 1.
  124.  
  125.      When the machine has more than 32 registers, an integer does not
  126.      suffice.  Then the integers are replaced by sub-initializers,
  127.      braced groupings containing several integers.  Each
  128.      sub-initializer must be suitable as an initializer for the type
  129.      `HARD_REG_SET' which is defined in `hard-reg-set.h'.
  130.  
  131. `REGNO_REG_CLASS (REGNO)'
  132.      A C expression whose value is a register class containing hard
  133.      register REGNO.  In general there is more than one such class;
  134.      choose a class which is "minimal", meaning that no smaller class
  135.      also contains the register.
  136.  
  137. `BASE_REG_CLASS'
  138.      A macro whose definition is the name of the class to which a valid
  139.      base register must belong.  A base register is one used in an
  140.      address which is the register value plus a displacement.
  141.  
  142. `INDEX_REG_CLASS'
  143.      A macro whose definition is the name of the class to which a valid
  144.      index register must belong.  An index register is one used in an
  145.      address where its value is either multiplied by a scale factor or
  146.      added to another register (as well as added to a displacement).
  147.  
  148. `REG_CLASS_FROM_LETTER (CHAR)'
  149.      A C expression which defines the machine-dependent operand
  150.      constraint letters for register classes.  If CHAR is such a
  151.      letter, the value should be the register class corresponding to
  152.      it.  Otherwise, the value should be `NO_REGS'.  The register
  153.      letter `r', corresponding to class `GENERAL_REGS', will not be
  154.      passed to this macro; you do not need to handle it.
  155.  
  156. `REGNO_OK_FOR_BASE_P (NUM)'
  157.      A C expression which is nonzero if register number NUM is suitable
  158.      for use as a base register in operand addresses.  It may be either
  159.      a suitable hard register or a pseudo register that has been
  160.      allocated such a hard register.
  161.  
  162. `REGNO_MODE_OK_FOR_BASE_P (NUM, MODE)'
  163.      A C expression that is just like `REGNO_OK_FOR_BASE_P', except that
  164.      that expression may examine the mode of the memory reference in
  165.      MODE.  You should define this macro if the mode of the memory
  166.      reference affects whether a register may be used as a base
  167.      register.  If you define this macro, the compiler will use it
  168.      instead of `REGNO_OK_FOR_BASE_P'.
  169.  
  170. `REGNO_OK_FOR_INDEX_P (NUM)'
  171.      A C expression which is nonzero if register number NUM is suitable
  172.      for use as an index register in operand addresses.  It may be
  173.      either a suitable hard register or a pseudo register that has been
  174.      allocated such a hard register.
  175.  
  176.      The difference between an index register and a base register is
  177.      that the index register may be scaled.  If an address involves the
  178.      sum of two registers, neither one of them scaled, then either one
  179.      may be labeled the "base" and the other the "index"; but whichever
  180.      labeling is used must fit the machine's constraints of which
  181.      registers may serve in each capacity.  The compiler will try both
  182.      labelings, looking for one that is valid, and will reload one or
  183.      both registers only if neither labeling works.
  184.  
  185. `PREFERRED_RELOAD_CLASS (X, CLASS)'
  186.      A C expression that places additional restrictions on the register
  187.      class to use when it is necessary to copy value X into a register
  188.      in class CLASS.  The value is a register class; perhaps CLASS, or
  189.      perhaps another, smaller class.  On many machines, the following
  190.      definition is safe:
  191.  
  192.           #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
  193.  
  194.      Sometimes returning a more restrictive class makes better code.
  195.      For example, on the 68000, when X is an integer constant that is
  196.      in range for a `moveq' instruction, the value of this macro is
  197.      always `DATA_REGS' as long as CLASS includes the data registers.
  198.      Requiring a data register guarantees that a `moveq' will be used.
  199.  
  200.      If X is a `const_double', by returning `NO_REGS' you can force X
  201.      into a memory constant.  This is useful on certain machines where
  202.      immediate floating values cannot be loaded into certain kinds of
  203.      registers.
  204.  
  205. `PREFERRED_OUTPUT_RELOAD_CLASS (X, CLASS)'
  206.      Like `PREFERRED_RELOAD_CLASS', but for output reloads instead of
  207.      input reloads.  If you don't define this macro, the default is to
  208.      use CLASS, unchanged.
  209.  
  210. `LIMIT_RELOAD_CLASS (MODE, CLASS)'
  211.      A C expression that places additional restrictions on the register
  212.      class to use when it is necessary to be able to hold a value of
  213.      mode MODE in a reload register for which class CLASS would
  214.      ordinarily be used.
  215.  
  216.      Unlike `PREFERRED_RELOAD_CLASS', this macro should be used when
  217.      there are certain modes that simply can't go in certain reload
  218.      classes.
  219.  
  220.      The value is a register class; perhaps CLASS, or perhaps another,
  221.      smaller class.
  222.  
  223.      Don't define this macro unless the target machine has limitations
  224.      which require the macro to do something nontrivial.
  225.  
  226. `SECONDARY_RELOAD_CLASS (CLASS, MODE, X)'
  227. `SECONDARY_INPUT_RELOAD_CLASS (CLASS, MODE, X)'
  228. `SECONDARY_OUTPUT_RELOAD_CLASS (CLASS, MODE, X)'
  229.      Many machines have some registers that cannot be copied directly
  230.      to or from memory or even from other types of registers.  An
  231.      example is the `MQ' register, which on most machines, can only be
  232.      copied to or from general registers, but not memory.  Some
  233.      machines allow copying all registers to and from memory, but
  234.      require a scratch register for stores to some memory locations
  235.      (e.g., those with symbolic address on the RT, and those with
  236.      certain symbolic address on the Sparc when compiling PIC).  In
  237.      some cases, both an intermediate and a scratch register are
  238.      required.
  239.  
  240.      You should define these macros to indicate to the reload phase
  241.      that it may need to allocate at least one register for a reload in
  242.      addition to the register to contain the data.  Specifically, if
  243.      copying X to a register CLASS in MODE requires an intermediate
  244.      register, you should define `SECONDARY_INPUT_RELOAD_CLASS' to
  245.      return the largest register class all of whose registers can be
  246.      used as intermediate registers or scratch registers.
  247.  
  248.      If copying a register CLASS in MODE to X requires an intermediate
  249.      or scratch register, `SECONDARY_OUTPUT_RELOAD_CLASS' should be
  250.      defined to return the largest register class required.  If the
  251.      requirements for input and output reloads are the same, the macro
  252.      `SECONDARY_RELOAD_CLASS' should be used instead of defining both
  253.      macros identically.
  254.  
  255.      The values returned by these macros are often `GENERAL_REGS'.
  256.      Return `NO_REGS' if no spare register is needed; i.e., if X can be
  257.      directly copied to or from a register of CLASS in MODE without
  258.      requiring a scratch register.  Do not define this macro if it
  259.      would always return `NO_REGS'.
  260.  
  261.      If a scratch register is required (either with or without an
  262.      intermediate register), you should define patterns for
  263.      `reload_inM' or `reload_outM', as required (*note Standard
  264.      Names::..  These patterns, which will normally be implemented with
  265.      a `define_expand', should be similar to the `movM' patterns,
  266.      except that operand 2 is the scratch register.
  267.  
  268.      Define constraints for the reload register and scratch register
  269.      that contain a single register class.  If the original reload
  270.      register (whose class is CLASS) can meet the constraint given in
  271.      the pattern, the value returned by these macros is used for the
  272.      class of the scratch register.  Otherwise, two additional reload
  273.      registers are required.  Their classes are obtained from the
  274.      constraints in the insn pattern.
  275.  
  276.      X might be a pseudo-register or a `subreg' of a pseudo-register,
  277.      which could either be in a hard register or in memory.  Use
  278.      `true_regnum' to find out; it will return -1 if the pseudo is in
  279.      memory and the hard register number if it is in a register.
  280.  
  281.      These macros should not be used in the case where a particular
  282.      class of registers can only be copied to memory and not to another
  283.      class of registers.  In that case, secondary reload registers are
  284.      not needed and would not be helpful.  Instead, a stack location
  285.      must be used to perform the copy and the `movM' pattern should use
  286.      memory as a intermediate storage.  This case often occurs between
  287.      floating-point and general registers.
  288.  
  289. `SECONDARY_MEMORY_NEEDED (CLASS1, CLASS2, M)'
  290.      Certain machines have the property that some registers cannot be
  291.      copied to some other registers without using memory.  Define this
  292.      macro on those machines to be a C expression that is non-zero if
  293.      objects of mode M in registers of CLASS1 can only be copied to
  294.      registers of class CLASS2 by storing a register of CLASS1 into
  295.      memory and loading that memory location into a register of CLASS2.
  296.  
  297.      Do not define this macro if its value would always be zero.
  298.  
  299. `SECONDARY_MEMORY_NEEDED_RTX (MODE)'
  300.      Normally when `SECONDARY_MEMORY_NEEDED' is defined, the compiler
  301.      allocates a stack slot for a memory location needed for register
  302.      copies.  If this macro is defined, the compiler instead uses the
  303.      memory location defined by this macro.
  304.  
  305.      Do not define this macro if you do not define
  306.      `SECONDARY_MEMORY_NEEDED'.
  307.  
  308. `SECONDARY_MEMORY_NEEDED_MODE (MODE)'
  309.      When the compiler needs a secondary memory location to copy
  310.      between two registers of mode MODE, it normally allocates
  311.      sufficient memory to hold a quantity of `BITS_PER_WORD' bits and
  312.      performs the store and load operations in a mode that many bits
  313.      wide and whose class is the same as that of MODE.
  314.  
  315.      This is right thing to do on most machines because it ensures that
  316.      all bits of the register are copied and prevents accesses to the
  317.      registers in a narrower mode, which some machines prohibit for
  318.      floating-point registers.
  319.  
  320.      However, this default behavior is not correct on some machines,
  321.      such as the DEC Alpha, that store short integers in floating-point
  322.      registers differently than in integer registers.  On those
  323.      machines, the default widening will not work correctly and you
  324.      must define this macro to suppress that widening in some cases.
  325.      See the file `alpha.h' for details.
  326.  
  327.      Do not define this macro if you do not define
  328.      `SECONDARY_MEMORY_NEEDED' or if widening MODE to a mode that is
  329.      `BITS_PER_WORD' bits wide is correct for your machine.
  330.  
  331. `SMALL_REGISTER_CLASSES'
  332.      On some machines, it is risky to let hard registers live across
  333.      arbitrary insns.  Typically, these machines have instructions that
  334.      require values to be in specific registers (like an accumulator),
  335.      and reload will fail if the required hard register is used for
  336.      another purpose across such an insn.
  337.  
  338.      Define `SMALL_REGISTER_CLASSES' to be an expression with a non-zero
  339.      value on these machines.  When this macro has a non-zero value, the
  340.      compiler will try to minimize the lifetime of hard registers.
  341.  
  342.      It is always safe to define this macro with a non-zero value, but
  343.      if you unnecessarily define it, you will reduce the amount of
  344.      optimizations that can be performed in some cases.  If you do not
  345.      define this macro with a non-zero value when it is required, the
  346.      compiler will run out of spill registers and print a fatal error
  347.      message.  For most machines, you should not define this macro at
  348.      all.
  349.  
  350. `CLASS_LIKELY_SPILLED_P (CLASS)'
  351.      A C expression whose value is nonzero if pseudos that have been
  352.      assigned to registers of class CLASS would likely be spilled
  353.      because registers of CLASS are needed for spill registers.
  354.  
  355.      The default value of this macro returns 1 if CLASS has exactly one
  356.      register and zero otherwise.  On most machines, this default
  357.      should be used.  Only define this macro to some other expression
  358.      if pseudos allocated by `local-alloc.c' end up in memory because
  359.      their hard registers were needed for spill registers.  If this
  360.      macro returns nonzero for those classes, those pseudos will only
  361.      be allocated by `global.c', which knows how to reallocate the
  362.      pseudo to another register.  If there would not be another
  363.      register available for reallocation, you should not change the
  364.      definition of this macro since the only effect of such a
  365.      definition would be to slow down register allocation.
  366.  
  367. `CLASS_MAX_NREGS (CLASS, MODE)'
  368.      A C expression for the maximum number of consecutive registers of
  369.      class CLASS needed to hold a value of mode MODE.
  370.  
  371.      This is closely related to the macro `HARD_REGNO_NREGS'.  In fact,
  372.      the value of the macro `CLASS_MAX_NREGS (CLASS, MODE)' should be
  373.      the maximum value of `HARD_REGNO_NREGS (REGNO, MODE)' for all
  374.      REGNO values in the class CLASS.
  375.  
  376.      This macro helps control the handling of multiple-word values in
  377.      the reload pass.
  378.  
  379. `CLASS_CANNOT_CHANGE_SIZE'
  380.      If defined, a C expression for a class that contains registers
  381.      which the compiler must always access in a mode that is the same
  382.      size as the mode in which it loaded the register.
  383.  
  384.      For the example, loading 32-bit integer or floating-point objects
  385.      into floating-point registers on the Alpha extends them to 64-bits.
  386.      Therefore loading a 64-bit object and then storing it as a 32-bit
  387.      object does not store the low-order 32-bits, as would be the case
  388.      for a normal register.  Therefore, `alpha.h' defines this macro as
  389.      `FLOAT_REGS'.
  390.  
  391.    Three other special macros describe which operands fit which
  392. constraint letters.
  393.  
  394. `CONST_OK_FOR_LETTER_P (VALUE, C)'
  395.      A C expression that defines the machine-dependent operand
  396.      constraint letters (`I', `J', `K', ... `P') that specify
  397.      particular ranges of integer values.  If C is one of those
  398.      letters, the expression should check that VALUE, an integer, is in
  399.      the appropriate range and return 1 if so, 0 otherwise.  If C is
  400.      not one of those letters, the value should be 0 regardless of
  401.      VALUE.
  402.  
  403. `CONST_DOUBLE_OK_FOR_LETTER_P (VALUE, C)'
  404.      A C expression that defines the machine-dependent operand
  405.      constraint letters that specify particular ranges of
  406.      `const_double' values (`G' or `H').
  407.  
  408.      If C is one of those letters, the expression should check that
  409.      VALUE, an RTX of code `const_double', is in the appropriate range
  410.      and return 1 if so, 0 otherwise.  If C is not one of those
  411.      letters, the value should be 0 regardless of VALUE.
  412.  
  413.      `const_double' is used for all floating-point constants and for
  414.      `DImode' fixed-point constants.  A given letter can accept either
  415.      or both kinds of values.  It can use `GET_MODE' to distinguish
  416.      between these kinds.
  417.  
  418. `EXTRA_CONSTRAINT (VALUE, C)'
  419.      A C expression that defines the optional machine-dependent
  420.      constraint letters (`Q', `R', `S', `T', `U') that can be used to
  421.      segregate specific types of operands, usually memory references,
  422.      for the target machine.  Normally this macro will not be defined.
  423.      If it is required for a particular target machine, it should
  424.      return 1 if VALUE corresponds to the operand type represented by
  425.      the constraint letter C.  If C is not defined as an extra
  426.      constraint, the value returned should be 0 regardless of VALUE.
  427.  
  428.      For example, on the ROMP, load instructions cannot have their
  429.      output in r0 if the memory reference contains a symbolic address.
  430.      Constraint letter `Q' is defined as representing a memory address
  431.      that does *not* contain a symbolic address.  An alternative is
  432.      specified with a `Q' constraint on the input and `r' on the
  433.      output.  The next alternative specifies `m' on the input and a
  434.      register class that does not include r0 on the output.
  435.  
  436. 
  437. File: gcc.info,  Node: Stack and Calling,  Next: Varargs,  Prev: Register Classes,  Up: Target Macros
  438.  
  439. Stack Layout and Calling Conventions
  440. ====================================
  441.  
  442.    This describes the stack layout and calling conventions.
  443.  
  444. * Menu:
  445.  
  446. * Frame Layout::
  447. * Stack Checking::
  448. * Frame Registers::
  449. * Elimination::
  450. * Stack Arguments::
  451. * Register Arguments::
  452. * Scalar Return::
  453. * Aggregate Return::
  454. * Caller Saves::
  455. * Function Entry::
  456. * Profiling::
  457.  
  458. 
  459. File: gcc.info,  Node: Frame Layout,  Next: Stack Checking,  Up: Stack and Calling
  460.  
  461. Basic Stack Layout
  462. ------------------
  463.  
  464.    Here is the basic stack layout.
  465.  
  466. `STACK_GROWS_DOWNWARD'
  467.      Define this macro if pushing a word onto the stack moves the stack
  468.      pointer to a smaller address.
  469.  
  470.      When we say, "define this macro if ...," it means that the
  471.      compiler checks this macro only with `#ifdef' so the precise
  472.      definition used does not matter.
  473.  
  474. `FRAME_GROWS_DOWNWARD'
  475.      Define this macro if the addresses of local variable slots are at
  476.      negative offsets from the frame pointer.
  477.  
  478. `ARGS_GROW_DOWNWARD'
  479.      Define this macro if successive arguments to a function occupy
  480.      decreasing addresses on the stack.
  481.  
  482. `STARTING_FRAME_OFFSET'
  483.      Offset from the frame pointer to the first local variable slot to
  484.      be allocated.
  485.  
  486.      If `FRAME_GROWS_DOWNWARD', find the next slot's offset by
  487.      subtracting the first slot's length from `STARTING_FRAME_OFFSET'.
  488.      Otherwise, it is found by adding the length of the first slot to
  489.      the value `STARTING_FRAME_OFFSET'.
  490.  
  491. `STACK_POINTER_OFFSET'
  492.      Offset from the stack pointer register to the first location at
  493.      which outgoing arguments are placed.  If not specified, the
  494.      default value of zero is used.  This is the proper value for most
  495.      machines.
  496.  
  497.      If `ARGS_GROW_DOWNWARD', this is the offset to the location above
  498.      the first location at which outgoing arguments are placed.
  499.  
  500. `FIRST_PARM_OFFSET (FUNDECL)'
  501.      Offset from the argument pointer register to the first argument's
  502.      address.  On some machines it may depend on the data type of the
  503.      function.
  504.  
  505.      If `ARGS_GROW_DOWNWARD', this is the offset to the location above
  506.      the first argument's address.
  507.  
  508. `STACK_DYNAMIC_OFFSET (FUNDECL)'
  509.      Offset from the stack pointer register to an item dynamically
  510.      allocated on the stack, e.g., by `alloca'.
  511.  
  512.      The default value for this macro is `STACK_POINTER_OFFSET' plus the
  513.      length of the outgoing arguments.  The default is correct for most
  514.      machines.  See `function.c' for details.
  515.  
  516. `DYNAMIC_CHAIN_ADDRESS (FRAMEADDR)'
  517.      A C expression whose value is RTL representing the address in a
  518.      stack frame where the pointer to the caller's frame is stored.
  519.      Assume that FRAMEADDR is an RTL expression for the address of the
  520.      stack frame itself.
  521.  
  522.      If you don't define this macro, the default is to return the value
  523.      of FRAMEADDR--that is, the stack frame address is also the address
  524.      of the stack word that points to the previous frame.
  525.  
  526. `SETUP_FRAME_ADDRESSES'
  527.      If defined, a C expression that produces the machine-specific code
  528.      to setup the stack so that arbitrary frames can be accessed.  For
  529.      example, on the Sparc, we must flush all of the register windows
  530.      to the stack before we can access arbitrary stack frames.  You
  531.      will seldom need to define this macro.
  532.  
  533. `BUILTIN_SETJMP_FRAME_VALUE'
  534.      If defined, a C expression that contains an rtx that is used to
  535.      store the address of the current frame into the built in `setjmp'
  536.      buffer.  The default value, `virtual_stack_vars_rtx', is correct
  537.      for most machines.  One reason you may need to define this macro
  538.      is if `hard_frame_pointer_rtx' is the appropriate value on your
  539.      machine.
  540.  
  541. `RETURN_ADDR_RTX (COUNT, FRAMEADDR)'
  542.      A C expression whose value is RTL representing the value of the
  543.      return address for the frame COUNT steps up from the current
  544.      frame, after the prologue.  FRAMEADDR is the frame pointer of the
  545.      COUNT frame, or the frame pointer of the COUNT - 1 frame if
  546.      `RETURN_ADDR_IN_PREVIOUS_FRAME' is defined.
  547.  
  548.      The value of the expression must always be the correct address when
  549.      COUNT is zero, but may be `NULL_RTX' if there is not way to
  550.      determine the return address of other frames.
  551.  
  552. `RETURN_ADDR_IN_PREVIOUS_FRAME'
  553.      Define this if the return address of a particular stack frame is
  554.      accessed from the frame pointer of the previous stack frame.
  555.  
  556. `INCOMING_RETURN_ADDR_RTX'
  557.      A C expression whose value is RTL representing the location of the
  558.      incoming return address at the beginning of any function, before
  559.      the prologue.  This RTL is either a `REG', indicating that the
  560.      return value is saved in `REG', or a `MEM' representing a location
  561.      in the stack.
  562.  
  563.      You only need to define this macro if you want to support call
  564.      frame debugging information like that provided by DWARF 2.
  565.  
  566. `INCOMING_FRAME_SP_OFFSET'
  567.      A C expression whose value is an integer giving the offset, in
  568.      bytes, from the value of the stack pointer register to the top of
  569.      the stack frame at the beginning of any function, before the
  570.      prologue.  The top of the frame is defined to be the value of the
  571.      stack pointer in the previous frame, just before the call
  572.      instruction.
  573.  
  574.      You only need to define this macro if you want to support call
  575.      frame debugging information like that provided by DWARF 2.
  576.  
  577. `ARG_POINTER_CFA_OFFSET'
  578.      A C expression whose value is an integer giving the offset, in
  579.      bytes, from the argument pointer to the canonical frame address
  580.      (cfa).  The final value should coincide with that calculated by
  581.      `INCOMING_FRAME_SP_OFFSET'.  Which is unfortunately not usable
  582.      during virtual register instantiation.
  583.  
  584.      You only need to define this macro if you want to support call
  585.      frame debugging information like that provided by DWARF 2.
  586.  
  587. 
  588. File: gcc.info,  Node: Stack Checking,  Next: Frame Registers,  Prev: Frame Layout,  Up: Stack and Calling
  589.  
  590. Specifying How Stack Checking is Done
  591. -------------------------------------
  592.  
  593.    GNU CC will check that stack references are within the boundaries of
  594. the stack, if the `-fstack-check' is specified, in one of three ways:
  595.  
  596.   1. If the value of the `STACK_CHECK_BUILTIN' macro is nonzero, GNU CC
  597.      will assume that you have arranged for stack checking to be done at
  598.      appropriate places in the configuration files, e.g., in
  599.      `FUNCTION_PROLOGUE'.  GNU CC will do not other special processing.
  600.  
  601.   2. If `STACK_CHECK_BUILTIN' is zero and you defined a named pattern
  602.      called `check_stack' in your `md' file, GNU CC will call that
  603.      pattern with one argument which is the address to compare the stack
  604.      value against.  You must arrange for this pattern to report an
  605.      error if the stack pointer is out of range.
  606.  
  607.   3. If neither of the above are true, GNU CC will generate code to
  608.      periodically "probe" the stack pointer using the values of the
  609.      macros defined below.
  610.  
  611.    Normally, you will use the default values of these macros, so GNU CC
  612. will use the third approach.
  613.  
  614. `STACK_CHECK_BUILTIN'
  615.      A nonzero value if stack checking is done by the configuration
  616.      files in a machine-dependent manner.  You should define this macro
  617.      if stack checking is require by the ABI of your machine or if you
  618.      would like to have to stack checking in some more efficient way
  619.      than GNU CC's portable approach.  The default value of this macro
  620.      is zero.
  621.  
  622. `STACK_CHECK_PROBE_INTERVAL'
  623.      An integer representing the interval at which GNU CC must generate
  624.      stack probe instructions.  You will normally define this macro to
  625.      be no larger than the size of the "guard pages" at the end of a
  626.      stack area.  The default value of 4096 is suitable for most
  627.      systems.
  628.  
  629. `STACK_CHECK_PROBE_LOAD'
  630.      A integer which is nonzero if GNU CC should perform the stack probe
  631.      as a load instruction and zero if GNU CC should use a store
  632.      instruction.  The default is zero, which is the most efficient
  633.      choice on most systems.
  634.  
  635. `STACK_CHECK_PROTECT'
  636.      The number of bytes of stack needed to recover from a stack
  637.      overflow, for languages where such a recovery is supported.  The
  638.      default value of 75 words should be adequate for most machines.
  639.  
  640. `STACK_CHECK_MAX_FRAME_SIZE'
  641.      The maximum size of a stack frame, in bytes.  GNU CC will generate
  642.      probe instructions in non-leaf functions to ensure at least this
  643.      many bytes of stack are available.  If a stack frame is larger
  644.      than this size, stack checking will not be reliable and GNU CC
  645.      will issue a warning.  The default is chosen so that GNU CC only
  646.      generates one instruction on most systems.  You should normally
  647.      not change the default value of this macro.
  648.  
  649. `STACK_CHECK_FIXED_FRAME_SIZE'
  650.      GNU CC uses this value to generate the above warning message.  It
  651.      represents the amount of fixed frame used by a function, not
  652.      including space for any callee-saved registers, temporaries and
  653.      user variables.  You need only specify an upper bound for this
  654.      amount and will normally use the default of four words.
  655.  
  656. `STACK_CHECK_MAX_VAR_SIZE'
  657.      The maximum size, in bytes, of an object that GNU CC will place in
  658.      the fixed area of the stack frame when the user specifies
  659.      `-fstack-check'.  GNU CC computed the default from the values of
  660.      the above macros and you will normally not need to override that
  661.      default.
  662.  
  663. 
  664. File: gcc.info,  Node: Frame Registers,  Next: Elimination,  Prev: Stack Checking,  Up: Stack and Calling
  665.  
  666. Registers That Address the Stack Frame
  667. --------------------------------------
  668.  
  669.    This discusses registers that address the stack frame.
  670.  
  671. `STACK_POINTER_REGNUM'
  672.      The register number of the stack pointer register, which must also
  673.      be a fixed register according to `FIXED_REGISTERS'.  On most
  674.      machines, the hardware determines which register this is.
  675.  
  676. `FRAME_POINTER_REGNUM'
  677.      The register number of the frame pointer register, which is used to
  678.      access automatic variables in the stack frame.  On some machines,
  679.      the hardware determines which register this is.  On other
  680.      machines, you can choose any register you wish for this purpose.
  681.  
  682. `HARD_FRAME_POINTER_REGNUM'
  683.      On some machines the offset between the frame pointer and starting
  684.      offset of the automatic variables is not known until after register
  685.      allocation has been done (for example, because the saved registers
  686.      are between these two locations).  On those machines, define
  687.      `FRAME_POINTER_REGNUM' the number of a special, fixed register to
  688.      be used internally until the offset is known, and define
  689.      `HARD_FRAME_POINTER_REGNUM' to be the actual hard register number
  690.      used for the frame pointer.
  691.  
  692.      You should define this macro only in the very rare circumstances
  693.      when it is not possible to calculate the offset between the frame
  694.      pointer and the automatic variables until after register
  695.      allocation has been completed.  When this macro is defined, you
  696.      must also indicate in your definition of `ELIMINABLE_REGS' how to
  697.      eliminate `FRAME_POINTER_REGNUM' into either
  698.      `HARD_FRAME_POINTER_REGNUM' or `STACK_POINTER_REGNUM'.
  699.  
  700.      Do not define this macro if it would be the same as
  701.      `FRAME_POINTER_REGNUM'.
  702.  
  703. `ARG_POINTER_REGNUM'
  704.      The register number of the arg pointer register, which is used to
  705.      access the function's argument list.  On some machines, this is
  706.      the same as the frame pointer register.  On some machines, the
  707.      hardware determines which register this is.  On other machines,
  708.      you can choose any register you wish for this purpose.  If this is
  709.      not the same register as the frame pointer register, then you must
  710.      mark it as a fixed register according to `FIXED_REGISTERS', or
  711.      arrange to be able to eliminate it (*note Elimination::.).
  712.  
  713. `RETURN_ADDRESS_POINTER_REGNUM'
  714.      The register number of the return address pointer register, which
  715.      is used to access the current function's return address from the
  716.      stack.  On some machines, the return address is not at a fixed
  717.      offset from the frame pointer or stack pointer or argument
  718.      pointer.  This register can be defined to point to the return
  719.      address on the stack, and then be converted by `ELIMINABLE_REGS'
  720.      into either the frame pointer or stack pointer.
  721.  
  722.      Do not define this macro unless there is no other way to get the
  723.      return address from the stack.
  724.  
  725. `STATIC_CHAIN_REGNUM'
  726. `STATIC_CHAIN_INCOMING_REGNUM'
  727.      Register numbers used for passing a function's static chain
  728.      pointer.  If register windows are used, the register number as
  729.      seen by the called function is `STATIC_CHAIN_INCOMING_REGNUM',
  730.      while the register number as seen by the calling function is
  731.      `STATIC_CHAIN_REGNUM'.  If these registers are the same,
  732.      `STATIC_CHAIN_INCOMING_REGNUM' need not be defined.
  733.  
  734.      The static chain register need not be a fixed register.
  735.  
  736.      If the static chain is passed in memory, these macros should not be
  737.      defined; instead, the next two macros should be defined.
  738.  
  739. `STATIC_CHAIN'
  740. `STATIC_CHAIN_INCOMING'
  741.      If the static chain is passed in memory, these macros provide rtx
  742.      giving `mem' expressions that denote where they are stored.
  743.      `STATIC_CHAIN' and `STATIC_CHAIN_INCOMING' give the locations as
  744.      seen by the calling and called functions, respectively.  Often the
  745.      former will be at an offset from the stack pointer and the latter
  746.      at an offset from the frame pointer.
  747.  
  748.      The variables `stack_pointer_rtx', `frame_pointer_rtx', and
  749.      `arg_pointer_rtx' will have been initialized prior to the use of
  750.      these macros and should be used to refer to those items.
  751.  
  752.      If the static chain is passed in a register, the two previous
  753.      macros should be defined instead.
  754.  
  755. 
  756. File: gcc.info,  Node: Elimination,  Next: Stack Arguments,  Prev: Frame Registers,  Up: Stack and Calling
  757.  
  758. Eliminating Frame Pointer and Arg Pointer
  759. -----------------------------------------
  760.  
  761.    This is about eliminating the frame pointer and arg pointer.
  762.  
  763. `FRAME_POINTER_REQUIRED'
  764.      A C expression which is nonzero if a function must have and use a
  765.      frame pointer.  This expression is evaluated  in the reload pass.
  766.      If its value is nonzero the function will have a frame pointer.
  767.  
  768.      The expression can in principle examine the current function and
  769.      decide according to the facts, but on most machines the constant 0
  770.      or the constant 1 suffices.  Use 0 when the machine allows code to
  771.      be generated with no frame pointer, and doing so saves some time
  772.      or space.  Use 1 when there is no possible advantage to avoiding a
  773.      frame pointer.
  774.  
  775.      In certain cases, the compiler does not know how to produce valid
  776.      code without a frame pointer.  The compiler recognizes those cases
  777.      and automatically gives the function a frame pointer regardless of
  778.      what `FRAME_POINTER_REQUIRED' says.  You don't need to worry about
  779.      them.
  780.  
  781.      In a function that does not require a frame pointer, the frame
  782.      pointer register can be allocated for ordinary usage, unless you
  783.      mark it as a fixed register.  See `FIXED_REGISTERS' for more
  784.      information.
  785.  
  786. `INITIAL_FRAME_POINTER_OFFSET (DEPTH-VAR)'
  787.      A C statement to store in the variable DEPTH-VAR the difference
  788.      between the frame pointer and the stack pointer values immediately
  789.      after the function prologue.  The value would be computed from
  790.      information such as the result of `get_frame_size ()' and the
  791.      tables of registers `regs_ever_live' and `call_used_regs'.
  792.  
  793.      If `ELIMINABLE_REGS' is defined, this macro will be not be used and
  794.      need not be defined.  Otherwise, it must be defined even if
  795.      `FRAME_POINTER_REQUIRED' is defined to always be true; in that
  796.      case, you may set DEPTH-VAR to anything.
  797.  
  798. `ELIMINABLE_REGS'
  799.      If defined, this macro specifies a table of register pairs used to
  800.      eliminate unneeded registers that point into the stack frame.  If
  801.      it is not defined, the only elimination attempted by the compiler
  802.      is to replace references to the frame pointer with references to
  803.      the stack pointer.
  804.  
  805.      The definition of this macro is a list of structure
  806.      initializations, each of which specifies an original and
  807.      replacement register.
  808.  
  809.      On some machines, the position of the argument pointer is not
  810.      known until the compilation is completed.  In such a case, a
  811.      separate hard register must be used for the argument pointer.
  812.      This register can be eliminated by replacing it with either the
  813.      frame pointer or the argument pointer, depending on whether or not
  814.      the frame pointer has been eliminated.
  815.  
  816.      In this case, you might specify:
  817.           #define ELIMINABLE_REGS  \
  818.           {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
  819.            {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
  820.            {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
  821.  
  822.      Note that the elimination of the argument pointer with the stack
  823.      pointer is specified first since that is the preferred elimination.
  824.  
  825. `CAN_ELIMINATE (FROM-REG, TO-REG)'
  826.      A C expression that returns non-zero if the compiler is allowed to
  827.      try to replace register number FROM-REG with register number
  828.      TO-REG.  This macro need only be defined if `ELIMINABLE_REGS' is
  829.      defined, and will usually be the constant 1, since most of the
  830.      cases preventing register elimination are things that the compiler
  831.      already knows about.
  832.  
  833. `INITIAL_ELIMINATION_OFFSET (FROM-REG, TO-REG, OFFSET-VAR)'
  834.      This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'.  It
  835.      specifies the initial difference between the specified pair of
  836.      registers.  This macro must be defined if `ELIMINABLE_REGS' is
  837.      defined.
  838.  
  839. `LONGJMP_RESTORE_FROM_STACK'
  840.      Define this macro if the `longjmp' function restores registers from
  841.      the stack frames, rather than from those saved specifically by
  842.      `setjmp'.  Certain quantities must not be kept in registers across
  843.      a call to `setjmp' on such machines.
  844.  
  845. 
  846. File: gcc.info,  Node: Stack Arguments,  Next: Register Arguments,  Prev: Elimination,  Up: Stack and Calling
  847.  
  848. Passing Function Arguments on the Stack
  849. ---------------------------------------
  850.  
  851.    The macros in this section control how arguments are passed on the
  852. stack.  See the following section for other macros that control passing
  853. certain arguments in registers.
  854.  
  855. `PROMOTE_PROTOTYPES'
  856.      Define this macro if an argument declared in a prototype as an
  857.      integral type smaller than `int' should actually be passed as an
  858.      `int'.  In addition to avoiding errors in certain cases of
  859.      mismatch, it also makes for better code on certain machines.
  860.  
  861. `PUSH_ROUNDING (NPUSHED)'
  862.      A C expression that is the number of bytes actually pushed onto the
  863.      stack when an instruction attempts to push NPUSHED bytes.
  864.  
  865.      If the target machine does not have a push instruction, do not
  866.      define this macro.  That directs GNU CC to use an alternate
  867.      strategy: to allocate the entire argument block and then store the
  868.      arguments into it.
  869.  
  870.      On some machines, the definition
  871.  
  872.           #define PUSH_ROUNDING(BYTES) (BYTES)
  873.  
  874.      will suffice.  But on other machines, instructions that appear to
  875.      push one byte actually push two bytes in an attempt to maintain
  876.      alignment.  Then the definition should be
  877.  
  878.           #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
  879.  
  880. `ACCUMULATE_OUTGOING_ARGS'
  881.      If defined, the maximum amount of space required for outgoing
  882.      arguments will be computed and placed into the variable
  883.      `current_function_outgoing_args_size'.  No space will be pushed
  884.      onto the stack for each call; instead, the function prologue should
  885.      increase the stack frame size by this amount.
  886.  
  887.      Defining both `PUSH_ROUNDING' and `ACCUMULATE_OUTGOING_ARGS' is
  888.      not proper.
  889.  
  890. `REG_PARM_STACK_SPACE (FNDECL)'
  891.      Define this macro if functions should assume that stack space has
  892.      been allocated for arguments even when their values are passed in
  893.      registers.
  894.  
  895.      The value of this macro is the size, in bytes, of the area
  896.      reserved for arguments passed in registers for the function
  897.      represented by FNDECL, which can be zero if GNU CC is calling a
  898.      library function.
  899.  
  900.      This space can be allocated by the caller, or be a part of the
  901.      machine-dependent stack frame: `OUTGOING_REG_PARM_STACK_SPACE' says
  902.      which.
  903.  
  904. `MAYBE_REG_PARM_STACK_SPACE'
  905. `FINAL_REG_PARM_STACK_SPACE (CONST_SIZE, VAR_SIZE)'
  906.      Define these macros in addition to the one above if functions might
  907.      allocate stack space for arguments even when their values are
  908.      passed in registers.  These should be used when the stack space
  909.      allocated for arguments in registers is not a simple constant
  910.      independent of the function declaration.
  911.  
  912.      The value of the first macro is the size, in bytes, of the area
  913.      that we should initially assume would be reserved for arguments
  914.      passed in registers.
  915.  
  916.      The value of the second macro is the actual size, in bytes, of the
  917.      area that will be reserved for arguments passed in registers.
  918.      This takes two arguments: an integer representing the number of
  919.      bytes of fixed sized arguments on the stack, and a tree
  920.      representing the number of bytes of variable sized arguments on
  921.      the stack.
  922.  
  923.      When these macros are defined, `REG_PARM_STACK_SPACE' will only be
  924.      called for libcall functions, the current function, or for a
  925.      function being called when it is known that such stack space must
  926.      be allocated.  In each case this value can be easily computed.
  927.  
  928.      When deciding whether a called function needs such stack space,
  929.      and how much space to reserve, GNU CC uses these two macros
  930.      instead of `REG_PARM_STACK_SPACE'.
  931.  
  932. `OUTGOING_REG_PARM_STACK_SPACE'
  933.      Define this if it is the responsibility of the caller to allocate
  934.      the area reserved for arguments passed in registers.
  935.  
  936.      If `ACCUMULATE_OUTGOING_ARGS' is defined, this macro controls
  937.      whether the space for these arguments counts in the value of
  938.      `current_function_outgoing_args_size'.
  939.  
  940. `STACK_PARMS_IN_REG_PARM_AREA'
  941.      Define this macro if `REG_PARM_STACK_SPACE' is defined, but the
  942.      stack parameters don't skip the area specified by it.
  943.  
  944.      Normally, when a parameter is not passed in registers, it is
  945.      placed on the stack beyond the `REG_PARM_STACK_SPACE' area.
  946.      Defining this macro suppresses this behavior and causes the
  947.      parameter to be passed on the stack in its natural location.
  948.  
  949. `RETURN_POPS_ARGS (FUNDECL, FUNTYPE, STACK-SIZE)'
  950.      A C expression that should indicate the number of bytes of its own
  951.      arguments that a function pops on returning, or 0 if the function
  952.      pops no arguments and the caller must therefore pop them all after
  953.      the function returns.
  954.  
  955.      FUNDECL is a C variable whose value is a tree node that describes
  956.      the function in question.  Normally it is a node of type
  957.      `FUNCTION_DECL' that describes the declaration of the function.
  958.      From this you can obtain the DECL_MACHINE_ATTRIBUTES of the
  959.      function.
  960.  
  961.      FUNTYPE is a C variable whose value is a tree node that describes
  962.      the function in question.  Normally it is a node of type
  963.      `FUNCTION_TYPE' that describes the data type of the function.
  964.      From this it is possible to obtain the data types of the value and
  965.      arguments (if known).
  966.  
  967.      When a call to a library function is being considered, FUNDECL
  968.      will contain an identifier node for the library function.  Thus, if
  969.      you need to distinguish among various library functions, you can
  970.      do so by their names.  Note that "library function" in this
  971.      context means a function used to perform arithmetic, whose name is
  972.      known specially in the compiler and was not mentioned in the C
  973.      code being compiled.
  974.  
  975.      STACK-SIZE is the number of bytes of arguments passed on the
  976.      stack.  If a variable number of bytes is passed, it is zero, and
  977.      argument popping will always be the responsibility of the calling
  978.      function.
  979.  
  980.      On the Vax, all functions always pop their arguments, so the
  981.      definition of this macro is STACK-SIZE.  On the 68000, using the
  982.      standard calling convention, no functions pop their arguments, so
  983.      the value of the macro is always 0 in this case.  But an
  984.      alternative calling convention is available in which functions
  985.      that take a fixed number of arguments pop them but other functions
  986.      (such as `printf') pop nothing (the caller pops all).  When this
  987.      convention is in use, FUNTYPE is examined to determine whether a
  988.      function takes a fixed number of arguments.
  989.  
  990.